<template>
    <div class="photo-info">
        <h4>{{ photoInfoObj.title }}</h4>
        <p class="photo-info-menu">
            <span>发表时间：{{ photoInfoObj.add_time | DateFormat }}</span>
            <span>点击：{{ photoInfoObj.click }}次</span>
        </p>

        <hr>
        <!--缩略图组件-->
        <preview :id="this.id"></preview>

        <div class="preview-info" v-html="photoInfoObj.content"></div>

        <!--评论组件-->
        <talk :id="this.id"></talk>
    </div>
</template>

<script>
    import { Toast } from 'mint-ui';
    //导入评论子组件
    import talk from '../subComment/talk.vue'

    //导入缩略图组件
    import preview from '../subComment/preview.vue'
    export default {
        data() {
            return {
                id: this.$route.params.id,
                photoInfoObj:{},
            }
        },
        created(){
            this.getphotoInfo();
        },

        methods:{
            //获取详情页信息
            getphotoInfo:function(){
                this.$http.get('api/getimageInfo/'+this.id).then(result =>{
                    if(result.body.status === 0){
                        this.photoInfoObj = result.body.message[0];
                    }else{
                        Toast({
                            message: '操作失败',
                            position: 'middle',
                            duration: 2000
                        });
                    }
                });
            },
        },
        components:{
            talk,
            preview,
        }
    }
</script>

<style lang="less">
    .photo-info{
        padding: 0 4px;
        
    }
    .my-gallery{
        margin-top: 16px;
    }
    figure{
        margin: 0 2% 8px 0;
        display: inline-block;
         width: 32%;
         &:nth-of-type(3n){
             margin-right: 0;
         }
        img{
            vertical-align: middle;
            width: 100%;
            height: auto;
        }
    }
    h4{
        font-size: 16px;
        color: #26a2ff;
        text-align: center;
        margin: 16px 0;
    }
    .photo-info-menu{
        display: flex;
        justify-content: space-between;
        align-content: center;
        span{
            font-size: 14px;
        }
    }

    .preview-info{
        font-size: 15px;
        line-height: 25px;
        text-indent: 30px;
        margin: 10px 0 20px;
    }
</style>
